package com.adou.p2p.page;

import lombok.Setter;

import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
@Setter
public class BasePage extends BaseRequest implements Pageable{
	protected int pageNumber = 0;

	protected int pageSize = PageConsts.DEFAULT_PAGE_SIZE;

	protected int offset = 0;

	protected Sort sort;

	public void setPageNumber(Integer pageNumber){
		if(pageNumber == null || pageNumber < 0 ||(pageNumber - 1) < 0) {
			pageNumber = PageConsts.DEFAULT_PAGE_NUMBER;
		} else {
			pageNumber  = pageNumber -1;
		}
		this.pageNumber  = pageNumber ;
	}
	
	@Override
	public int getPageNumber() {
		return pageNumber;
	}

	public void setPageSize(Integer pageSize) {
		if(pageSize == null || pageSize < 1 || pageSize > PageConsts.DEFAULT_PAGE_SIZE){
			pageSize = PageConsts.DEFAULT_PAGE_SIZE;
		} 
		this.pageSize = pageSize;
	}
	
	@Override
	public int getPageSize(){
		return pageSize;
	}
	
	@Override
	public long getOffset(){
		return offset;
	}
	
	public Sort getSort(){
		return sort;
	}
	   
	   @Override
	   public Pageable next(){
	   return null;
	   }
	   
	   @Override
		public Pageable previousOrFirst() {
			// TODO Auto-generated method stub
			return null;
		}
	   
	   @Override
	   public Pageable first(){
		   return null;
	   }
	   
	   	@Override
		public boolean hasPrevious() {
			// TODO Auto-generated method stub
			return false;
	   	}
}
